package com.lehoon.tomato.service.impl;

import com.lehoon.tomato.mapper.StoreGoodsMapper;
import com.lehoon.tomato.model.Store;
import com.lehoon.tomato.mapper.StoreMapper;
import com.lehoon.tomato.model.vo.StoreVo;
import com.lehoon.tomato.service.StoreService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author wang
 * @since 2020-09-23
 */
@Service
public class StoreServiceImpl implements StoreService {

    @Resource
    private StoreMapper storeMapper;
    @Resource
    private StoreGoodsMapper storeGoodsMapper;

    @Override
    public List<StoreVo> getStoreList(Integer schoolId, Integer bedroomId) {
        List<StoreVo> list = storeMapper.getStoreList(schoolId,bedroomId);
        for (StoreVo vo:list){
            int num = storeGoodsMapper.countSaleGoods(vo.getId());
            vo.setGoodsTypeNum(num);
        }
        return list;
    }
}
